/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.6;
}

/* 主容器样式 */
.dashboard-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* 顶部导航栏 */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0 20px;
    height: 60px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.logo h1 {
    font-size: 20px;
    font-weight: 600;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* 按钮样式 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn.primary {
    background-color: #28a745;
    color: white;
}

.btn.primary:hover {
    background-color: #218838;
}

.btn-link {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    text-decoration: underline;
}

.btn-link:hover {
    color: #764ba2;
}

/* 通知图标 */
.notification-icon {
    position: relative;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.notification-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.notification-icon .bell {
    font-size: 20px;
}

.notification-icon .badge {
    position: absolute;
    top: 0;
    right: 0;
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* 用户头像 */
.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    backdrop-filter: blur(10px);
}

/* 主布局容器 */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    width: 220px;
    background-color: #ffffff;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    transition: all 0.3s ease;
    z-index: 100;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.nav-item:hover {
    background-color: #f8f9fa;
}

.nav-item.active {
    background-color: #e7f1ff;
    border-left-color: #667eea;
    color: #667eea;
    font-weight: 500;
}

.nav-item .icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

/* 主内容区 */
.main-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #f0f2f5;
}

/* 仪表盘样式 */
.dashboard {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.dashboard.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
}

.dashboard-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: white;
    font-size: 14px;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 统计卡片 */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.stat-header h3 {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.stat-header .unit {
    font-size: 12px;
    color: #999;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 5px;
}

.stat-trend {
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 12px;
}

.stat-trend.positive {
    background-color: #d4edda;
    color: #155724;
}

.stat-trend.negative {
    background-color: #f8d7da;
    color: #721c24;
}

.stat-trend.critical {
    background-color: #ffc107;
    color: #856404;
}

/* 图表网格 */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.chart-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.chart-card.full-width {
    grid-column: 1 / -1;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.chart-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.live {
    background-color: #28a745;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(40, 167, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

.performance-indicator {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* 告警部分 */
.alerts-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.alerts-list {
    max-height: 300px;
    overflow-y: auto;
}

/* 告警项 */
.alert-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    background-color: #f8f9fa;
    border-left: 4px solid #6c757d;
}

.alert-item.critical {
    border-left-color: #dc3545;
    background-color: #fff5f5;
}

.alert-item.warning {
    border-left-color: #ffc107;
    background-color: #fffbf0;
}

.alert-item.info {
    border-left-color: #17a2b8;
    background-color: #f0f9ff;
}

.alert-icon {
    font-size: 20px;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.alert-time {
    font-size: 12px;
    color: #6c757d;
}

.alert-status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.alert-status.unread {
    background-color: #667eea;
    color: white;
}

.alert-status.read {
    background-color: #6c757d;
    color: white;
}

/* 表格样式 */
.alerts-table-container {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    overflow-x: auto;
}

.alerts-table {
    width: 100%;
    border-collapse: collapse;
}

.alerts-table th,
.alerts-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.alerts-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
    position: sticky;
    top: 0;
    z-index: 10;
}

.alerts-table tbody tr:hover {
    background-color: #f8f9fa;
}

/* 面板样式 */
.notification-panel,
.history-panel,
.settings-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

.notification-panel.active,
.history-panel.active,
.settings-panel.active {
    right: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.panel-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* 通知列表 */
.notifications-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.notification-item {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    background-color: #f8f9fa;
    border-left: 4px solid #667eea;
    cursor: pointer;
    transition: all 0.3s ease;
}

.notification-item:hover {
    transform: translateX(-5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.notification-item.unread {
    background-color: #e7f1ff;
}

.notification-time {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 5px;
}

.notification-message {
    font-size: 14px;
    color: #495057;
}

/* 历史回放控件 */
.history-controls {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.date-range {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.date-range label {
    font-size: 14px;
    font-weight: 500;
    color: #495057;
}

.date-range input[type="datetime-local"] {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
}

.playback-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.playback-controls .btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background-color: #667eea;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.speed-control label {
    font-size: 14px;
    font-weight: 500;
    color: #495057;
}

.speed-control input[type="range"] {
    flex: 1;
}

/* 设置内容 */
.settings-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.setting-group {
    margin-bottom: 25px;
}

.setting-group h4 {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e9ecef;
}

.threshold-setting,
.notification-setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 8px 0;
}

.threshold-setting label,
.notification-setting label {
    font-size: 14px;
    color: #495057;
}

.threshold-setting input[type="number"] {
    width: 80px;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* 设备网格 */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.device-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.device-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.device-name {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.device-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.device-status.online {
    background-color: #d4edda;
    color: #155724;
}

.device-status.offline {
    background-color: #f8d7da;
    color: #721c24;
}

.device-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

.device-metric {
    font-size: 12px;
    color: #6c757d;
}

.device-metric .value {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    display: block;
    margin-top: 4px;
}

/* 性能指标 */
.performance-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.metric-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.metric-name {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.metric-value {
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
}

.metric-bar {
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.metric-progress {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
}

/* 加载遮罩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    color: #667eea;
    font-size: 16px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .navbar .logo h1 {
        font-size: 16px;
    }
    
    .nav-controls {
        gap: 10px;
    }
    
    .nav-controls .btn {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .sidebar {
        width: 200px;
    }
    
    .stats-cards {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .notification-panel,
    .history-panel,
    .settings-panel {
        width: 100%;
        right: -100%;
    }
}